package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishFlavorDto;
import com.sky.dto.DishPageDto;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    Page<Dish> queryByPage(DishPageDto dishPageDto);
    @AutoFill(OperationType.INSERT)
    void insert(Dish dishFlavorDto);

    List<Dish> listDishes(Long categoryId);
    @AutoFill(OperationType.UPDATE)
    void modifyStatus(Dish dish);

    int countByCategoryId(Long categoryId);

    Dish queryById(Long id);
    @AutoFill(OperationType.UPDATE)
    void modifyDish(DishFlavorDto dishFlavorDto);
    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);
    @Select("select count(0) from dish where status = 1")
    Integer getSold();
    @Select("select count(0) from dish where status = 0")
    Integer getDiscontinued();
}
